<?php /* Smarty version 2.6.26, created on 2011-12-07 22:42:22
         compiled from info.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'info.tpl', 12, false),)), $this); ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => 'header.tpl', 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

<h3>info</h3> 
 <hr>
 <?php echo $this->_tpl_vars['infoTable']; ?>

 <h3>添加</h3>
 <form name="form1" id="form1" action="<?php echo $this->_tpl_vars['baseUrl']; ?>
info/addInfo" method="post">
<input type="hidden" name="id" value="<?php echo $this->_tpl_vars['id']; ?>
" />
<p>店铺名称<input type="text" name="name" value="<?php echo $this->_tpl_vars['name']; ?>
" /></p>
<p>店铺类别 
            <select name="class">
             <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['class_options'],'selected' => $this->_tpl_vars['class_id']), $this);?>

             </select>
</p>
<p>地址:<input type="text" name="address" value="<?php echo $this->_tpl_vars['addres']; ?>
"/></p>
<p>google地址<input type="text" name="google_address" value="<?php echo $this->_tpl_vars['google']; ?>
"/></p>
<p><input type="hidden" name="ico" id="ico"  value="<?php echo $this->_tpl_vars['ico']; ?>
"><span id="ico_tip">请先上传logo</span></p>
<p><input type="hidden" name="pic" id="pic"  value="<?php echo $this->_tpl_vars['pic']; ?>
" ><span id="pic_tip">请先上传宣传图</span></p>
 </form>

<h3>上传商店ico图片</h3>
<form action="<?php echo $this->_tpl_vars['baseUrl']; ?>
photo/upPic?callback=ico&scaleX=200" enctype="multipart/form-data" method="post" target='pic' >
<input  name='file[]' type='file'></input>
<input type='submit' value='上传' />
</form>
<p>移动方框，双击裁剪</p>
<div id='ico_pic'>
<img src="<?php echo $this->_tpl_vars['ico']; ?>
" />

</div>
<h3>上传商店宣传图片</h3>
<form action="<?php echo $this->_tpl_vars['baseUrl']; ?>
photo/upPic?callback=pic&scaleX=200" enctype="multipart/form-data" method="post" target='pic' >
<input  name='file[]' type='file'></input>
<input type='submit' value='上传' />
</form>
<p>移动方框，双击裁剪</p>
<div id='ad_pic'>

<img src="<?php echo $this->_tpl_vars['pic']; ?>
" />
</div>

<iframe name='pic' style='display:none;'> </iframe>
<input id="save" type="button" value="保存"></input>



 <!---js 开始-->

<?php echo '
<style>
.cut_pic_box{
    padding:2px;    
    border:1px #ccc dotted;
    
    
}
.cut_pic{
    position:relative;
    background:url(/iweber_amxx/upload/pics/i1jTw-1322738711.jpg) top left no-repeat;
    overflow:hidden;
}
.cut_shadow{
    position:absolute;
    width:100%;    
    height:100%;
    background:#000;
    filter: alpha(opacity=80);
    -moz-opacity:0.8;
    opacity: 0.8;
}
.cut_ico{
    position:absolute;
    width:200px;
    height:200px;
    cursor:move;
    background:url(/iweber_amxx/upload/pics/i1jTw-1322738711.jpg) no-repeat;
    background-position:0px 0px;
    overflow:hidden;

}
</style>
<script src=\''; ?>
<?php echo $this->_tpl_vars['baseUrl']; ?>
<?php echo 'public/jquery.js\' ></script>

<script>

$(\'#save\').click(function(){

    $("#form1").submit();  
    
});


/*裁剪框相关js---start-----------*/
    function ico(data){
       var json=eval(\'(\'+data+\')\'); 
       var rect={};
       rect.x=0;
       rect.y=0;
       rect.w=50;
       rect.h=50;
       cutPic(json["pics"][0],\'photo/cutPic\',\'ico_pic\',rect,function(data){
           
        $("#ico").val(data);    
        $("#ico_tip").html("上传成功");
           
        });
    }
    function pic(data){
       var json=eval(\'(\'+data+\')\'); 
       var rect={};
       rect.x=50;
       rect.y=50;
       rect.w=200;
       rect.h=200;
       cutPic(json["pics"][0],\'photo/cutPic\',\'ad_pic\',rect,function(data){
           
        $("#pic").val(data);    
        $("#pic_tip").html("上传成功");
           
        });
    }
    
    //图片地址，handleUrl地址,container的id，rect为裁剪框的矩形,callback函数
function cutPic(picUrl,handleUrl,container,rect,callback){
    //获取图片大小  
    $=jQuery;
    $("#"+container).html("");
    str ="<div id=\'"+container+"_cut_pic_box\' class=\'cut_pic_box\'>";
    str+="  <div id=\'"+container+"_cut_pic\' class=\'cut_pic\'>";
    str+="      <div class=\'cut_shadow\'>";
    str+="      </div>";
    str+="      <div title=\'双击裁剪\' id=\'"+container+"_cut_ico\' class=\'cut_ico\'>";
    str+="      </div>";
    str+="  </div>";
    str+="</div>";
    str+="<img id=\'"+container+"_cut_image\' style=\'display:none\' src=\'"+picUrl+"\' />";
    $("#"+container).append(str);

    var x=rect.x;
    var y=rect.y;
    var w=rect.w;
    var h=rect.h;

    $("#"+container+"_cut_image").load(function(){


            width=$(this).width();
            height=$(this).height();
            $("#"+container+"_cut_pic").height(height);
            $("#"+container+"_cut_pic").width(width);
            $("#"+container+"_cut_pic").css("background","url("+picUrl+")");
            $("#"+container+"_cut_ico").css("background","url("+picUrl+")");
            $("#"+container+"_cut_ico").css("width",w);
            $("#"+container+"_cut_ico").css("height",h);
            $("#"+container+"_cut_ico").css("top",y);
            $("#"+container+"_cut_ico").css("left",x);
            var v=-x+"px "+(-y+"px");
            $(\'#\'+container+\'_cut_ico\').css(\'background-position\',v);
            $("#"+container+"_cut_ico").mousedown(function(e){
                var startX=e.clientX;
                var startY=e.clientY;
                var orginX=this.offsetLeft;
                var orginY=this.offsetTop;
                var deltaX=startX-orginX;
                var deltaY=startY-orginY;

                $(\'#\'+container+\'_cut_ico\').mousemove(drag);

                $(\'#\'+container+\'_cut_ico\').mouseup(function(e){
                    $(\'#\'+container+\'_cut_ico\').unbind(\'mousemove\',drag); 
                    })
                $(\'#\'+container+\'_cut_ico\').mouseout(function(e){
                    $(\'#\'+container+\'_cut_ico\').unbind(\'mousemove\',drag); 
                    });       

                //拖动函数绑定mousemove事件
                function drag(e){
                x=e.clientX-deltaX;
                y=e.clientY-deltaY;
                //console.log("(x:"+x+",y:"+y+")");
                w=$(\'#\'+container+\'_cut_ico\').width(); 
                h=$(\'#\'+container+\'_cut_ico\').height();
                bw=$(\'#\'+container+\'_cut_pic\').width();
                bh=$(\'#\'+container+\'_cut_pic\').height();
                //边界控制
                if(x+w>bw){
                    x=bw-w-2;
                }
                if(y+h>bh){
                    y=bh-h-2;
                }
                if(y<0){
                    y=2;
                }
                if(x<0){
                    x=2
                }
                var v=-x+"px "+(-y+"px");
                $(\'#\'+container+\'_cut_ico\').css(\'background-position\',v);
                $(\'#\'+container+\'_cut_ico\').css({top:y,left:x});

                }
                return false;

            });
        $("#"+container+"_cut_ico").dblclick(function(e){
            $.get(handleUrl, { "x":x,"y":y,"w":w,"h":h,"url":picUrl},
                function(data){
                    var img="<img src=\'"+data+"?"+(new Date().getTime())+"\' />";
                    $("#"+container).html(img);
                    callback(data)
                
                }); 
            
        });

    });  

}
/*裁剪框相关js---end-----------*/
    

</script>
'; ?>


<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => 'footer.tpl', 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>